/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package aso.upna.cancion;

import java.io.File;

/**
 *
 * @author triki
 */

public abstract class AbstractCancion {
    protected String filename;
    protected String duracion;
    
    protected Metadata metadatos;
    
    public AbstractCancion(String file)
    {
        filename = new String(file);
        duracion="";
    }

    public String getFilename()
    {
        return filename;
    }
    
    public String getDuracion()
    {
        return duracion;
    }

    /*public void calcular_duracion()
    {
        File curr_file = new File(getRealPath());
        AudioFile audioFile = AudioFileIO.read(curr_file);

            if(audioFile == null)
                return;
            duracion = convertDuration(audioFile.getLength());
    }*/
    
    abstract public void calcular_duracion();
    abstract public boolean is_local();
    abstract public String getPath();
    abstract public String getRealPath();
    
    public static String convertDuration(int duration)
    {
        String aux = "";

        int hour;
        int min;
        int seg;

        hour = duration / 3600;
        min = duration / 60;
        seg = duration % 60;
        seg = (seg*60)/100;

        if(hour >= 1)
        {
            aux = hour+":"+min+":"+seg;
        }
        else
        {
            aux +=min+":";
            if(seg < 10)
                aux+="0";
            aux +=seg;
        }

        return new String(aux);
    }

    public boolean hasMetadata()
    {
        if(metadatos == null)
            return false;
        return true;
    }

    public Metadata getMetadatos()
    {
        return this.metadatos;
    }
}
